package live.ciallo.discipline.service;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
@AllArgsConstructor
@Slf4j
public class NeowSendMessageImpl implements SendMessage {

    private final RestTemplate restTemplate;

    private static final String NEOW_URL = "https://api.chuckfang.com/%s/%s/%s";
    @Override
    public void sendMessage(String userId, String title, String content) {
        String url = String.format(NEOW_URL, userId, title, content);
        ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.GET, null, String.class);
        log.info("Neow发送消息返回：{}", exchange.getBody());
    }
}
